import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.io.Serializable;

public class FilledRectangleObject extends ShapeObject implements Serializable{

	public FilledRectangleObject(Point startingMousePosition,Point endingMousePosition, Color color) {
		super(new Point(Math.min(startingMousePosition.x, endingMousePosition.x), 
				Math.min(startingMousePosition.y, endingMousePosition.y)), 
				new Point(Math.max(startingMousePosition.x, endingMousePosition.x), 
						Math.max(startingMousePosition.y, endingMousePosition.y)), color);
	}


	protected DrawingCanvas canvas;


	public void drawShape(DrawingCanvas canvas){

		int x= startingMousePosition.x;
		int y=startingMousePosition.y; 
		int width=endingMousePosition.x-startingMousePosition.x; 
		int height=endingMousePosition.y-startingMousePosition.y;
		int rectX = x;
		int rectY = y;
		int rectWidth = width;
		int rectHeight = height;
		if (width < 0) {
			rectX = x + width;
			rectWidth = -width;
		} 
		if (height < 0) {
			rectY = y + height;
			rectHeight = -height;
		}
		Graphics iBGraphics = canvas.getImageBufferGraphics();
		iBGraphics.setColor(this.color);
		iBGraphics.fillRect(rectX, rectY, rectWidth, rectHeight);

		canvas.repaint();
	}

	public boolean isResizeable() {
		return true;
	}


}
